<!DOCTYPE html>
<style>
#content {
  width: 750px;
  height: 10000px;
  background-color: blue;
}
</style>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<div id="content"></div>
<div id="console"></div>
<script>

jsTestIsAsync = true;

var prevScrollY;
var scrollStart;

function runTest() {
    internals.settings.setScrollAnimatorEnabled(true);

    window.addEventListener("scroll", onWindowScroll);

    runAfterLayoutAndPaint(function() {
        eventSender.keyDown('End');
    });
}

function onWindowScroll() {
    if (typeof prevScrollY === 'undefined') {
        shouldNotBe("window.scrollY",
                    "document.body.scrollHeight - window.innerHeight");
        shouldBeGreaterThan("window.scrollY", "0");
        prevScrollY = window.scrollY;

        if (window.scrollY === document.body.scrollHeight - window.innerHeight) {
            // We wont get another scroll event. The failure was reported above
            // but return early to prevent a timeout.
            finishJSTest();
        }
    } else {
        shouldBeGreaterThan("window.scrollY", "prevScrollY");
        finishJSTest();
    }
}

description("Tests that overflow scrolls on the root frame are animated.");

if (window.eventSender)
    runTest();
else
    debug("FAIL: This test requires window.eventSender.");

</script>
